<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item label="挂号单ID" prop="registerId">
        <el-input
          v-model="queryParams.registerId"
          placeholder="请输入正确的挂号单ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
        <el-button type="primary" icon="el-icon-search" size="mini" >读取IC卡</el-button>
      </el-form-item>
    </el-form>
    <button @click="te01">支付宝测试</button>
    <div v-if="postList.prOrReOrCa !=null">
      <div>挂号单号:{{prOrReOrCa.outpatientCase.registerId}}</div><div>科室名称:{{postList.deptName}}</div>

      <div>医生姓名:{{postList.docktorName}}</div>
      <div>患者姓名:{{postList.patientName}}</div>
      <div>就诊时间:{{prOrReOrCa.outpatientRegister.registerTime}}</div>
      <div>主诉:{{postList.prOrReOrCa.outpatientCase.chiefComplaint}}</div>
      <div>诊断信息:{{postList.prOrReOrCa.outpatientCase.diagnose}}</div>
      <div>医生建议:{{postList.prOrReOrCa.outpatientCase.advise}}</div>
      <br/>
<!--      <el-button @click="pay1">现金</el-button>-->
<!--      <el-button>支付宝</el-button>-->

      <el-row :gutter="10" class="mb8">
        <el-col :span="2" >
          <el-button
            type="warning"
            round

            size="mini"
            @click="pay1"
          >现金</el-button>
        </el-col>
        <el-col :span="2">
          <el-button
            type="warning"
            round

            size="mini"

            @click="pay1"
          >支付宝</el-button>
        </el-col>

        <right-toolbar :showSearch.sync="showSearch" @queryTable=""></right-toolbar>
      </el-row>


      订单金额:
      <br/>

      <el-table v-loading="loading" :data="prOrReOrCa.outpatientPrescription" @selection-change="handleSelectionChange">

        <el-table-column type="selection" width="55" align="center"  />
        <el-table-column label="处方单号" align="center" key="prescriptionId"  prop="prescriptionId" />
        <el-table-column label="药品名称" align="center" key="medicine" prop="medicine" />
        <el-table-column label="数量" align="center" key="medicineNum"  prop="medicineNum" />
        <el-table-column label="单价(元)" align="center" key="medicinePrice"  prop="medicinePrice" />
        <el-table-column label="总金额(元)" align="center" key="countMoney"  prop="countMoney" />
        <el-table-column label="服用备注" align="center" key="medicineNotes"  prop="medicineNotes" />
        <el-table-column label="支付状态" align="center" key="status"  prop="status" :formatter="statusFormat" />

      </el-table>
    </div>




  </div>
</template>

<script>
import { listMenu, getMenu, delMenu, addMenu, updateMenu } from "@/api/system/menu";
import {selectPrescription,xpay,zpay,te} from '@/api/syl_LiBiao/chargeManagement'
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";


export default {
  name: "shoufei",
  components: { Treeselect, IconSelect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 岗位表格数据
      postList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      ma:false,
      // 状态数据字典
      statusOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        registerId: '0',
      },
      // 表单参数
      form: {},
      // 表单校验

      prOrReOrCa:{
        outpatientCase: [],
        outpatientPrescription:[],
        outpatientRegister:[]
      },
    };
  },
  created() {

    this.getDicts("order_pay_status").then(response => {
      this.statusOptions = response.data;

    });
  },
  methods: {

    // 岗位状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },

    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.prescriptionId)

      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    te01(){
      te().then(resule =>{

      })
    },
    pay1(){
      const postId ={
        "ids":this.ids
      }
      console.log(postId);
      xpay(postId).then(result =>{
        console.log(result);
      })

    },
    /**
     * 根据挂号id查询处方信息
     */
    handleQuery() {
      this.loading=true;
      selectPrescription(this.queryParams).then(result =>{
        this.postList=result.data;
        this.prOrReOrCa.outpatientCase=result.data.prOrReOrCa.outpatientCase;
        this.prOrReOrCa.outpatientPrescription=result.data.outpatientPrescriptions;
        this.prOrReOrCa.outpatientRegister=result.data.prOrReOrCa.outpatientRegister;
        this.loading=false;
      });

    }
  }
};
</script>
